package com.tgr.shortLink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tgr.shortLink.admin.common.convention.result.Result;
import com.tgr.shortLink.admin.common.convention.result.Results;
import com.tgr.shortLink.admin.remote.ShortLinkActualRemoteService;
import com.tgr.shortLink.admin.remote.dto.req.RecycleBinRecoverReqDTO;
import com.tgr.shortLink.admin.remote.ShortLinkRemoteService;
import com.tgr.shortLink.admin.remote.dto.req.RecycleBinPageReqDTO;
import com.tgr.shortLink.admin.remote.dto.req.RecycleBinRemoveReqDTO;
import com.tgr.shortLink.admin.remote.dto.req.RecycleBinSaveReqDTO;
import com.tgr.shortLink.admin.remote.dto.resp.RecycleBinPageRespDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述：
 * 作者：小陶不慌张
 * 文件：RecycleBinController
 * 日期：2024/1/23 12:27
 */
@RestController(value = "recycleBinControllerAdmin")
@RequiredArgsConstructor
public class RecycleBinController {
    ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){
    };
    private final ShortLinkActualRemoteService shortLinkActualRemoteService;

    @PostMapping("/api/short-link/admin/v1/recycle-bin/save")
    public Result<Void> saveBin(@RequestBody RecycleBinSaveReqDTO requestParam){
        shortLinkActualRemoteService.saveBin(requestParam);
        return Results.success();
    }

    @GetMapping("/api/short-link/admin/v1/recycle-bin/page")
    public Result<IPage<RecycleBinPageRespDTO>> pageLink(RecycleBinPageReqDTO requestParam){
        return shortLinkActualRemoteService.pageBin(requestParam);
    }

    @PostMapping("/api/short-link/admin/v1/recycle-bin/recover")
    public Result<Void> recoverBin(@RequestBody RecycleBinRecoverReqDTO requestParam){
        shortLinkActualRemoteService.recoverBin(requestParam);
        return Results.success();
    }

    @PostMapping("/api/short-link/admin/v1/recycle-bin/remove")
    private Result<Void> removeBin(@RequestBody RecycleBinRemoveReqDTO requestParam){
        shortLinkActualRemoteService.removeBin(requestParam);
        return Results.success();
    }
}
